global _start
extern func6D61696E2829 ; main()
global func6F70657273646528696E742629 ; opersde(int&)
global func6F70657275646528696E742629 ; operude(int&)
global func6F70657273696E28696E742629 ; opersin(int&)
global func6F70657275696E28696E742629 ; operuin(int&)
global func6F70657261616428696E74262C696E7429 ; operaad(int&,int)
global func6F70657261737528696E74262C696E7429 ; operasu(int&,int)
global func6F706572616D7528696E74262C696E7429 ; operamu(int&,int)
global func6F70657261646928696E74262C696E7429 ; operadi(int&,int)
global func6F706572616D6F28696E74262C696E7429 ; operamo(int&,int)
global func6F70657261737228696E74262C696E7429 ; operasr(int&,int)
global func6F70657261736C28696E74262C696E7429 ; operasl(int&,int)
global func6F70657261646428696E742C696E7429 ; operadd(int,int)
global func6F70657273756228696E742C696E7429 ; opersub(int,int)
global func6F7065726D756C28696E742C696E7429 ; opermul(int,int)
global func6F70657264697628696E742C696E7429 ; operdiv(int,int)
global func6F7065726D6F6428696E742C696E7429 ; opermod(int,int)
global func6F70657273687228696E742C696E7429 ; opershr(int,int)
global func6F70657273686C28696E742C696E7429 ; opershl(int,int)
global func6F706572786F7228696E742C696E7429 ; operxor(int,int)
global func6F70657262616E28696E742C696E7429 ; operban(int,int)
global func6F706572626F7228696E742C696E7429 ; operbor(int,int)
global func6F70657261786F28696E74262C696E7429 ; operaxo(int&,int)
global func6F70657261616E28696E74262C696E7429 ; operaan(int&,int)
global func6F706572616F7228696E74262C696E7429 ; operaor(int&,int)
global func6F7065726164642873616D652A2C696E7429 ; operadd(same*,int)
global func6F7065727375622873616D652A2C696E7429 ; opersub(same*,int)
global func6F7065726161642873616D652A262C696E7429 ; operaad(same*&,int)
global func6F7065726173752873616D652A262C696E7429 ; operasu(same*&,int)
global func6F70657275696E2873616D652A2629 ; operuin(same*&)
global func6F70657273696E2873616D652A2629 ; opersin(same*&)
global func6F7065727564652873616D652A2629 ; operude(same*&)
global func6F7065727364652873616D652A2629 ; opersde(same*&)
global func6F70657265717528636861722C6368617229 ; operequ(char,char)
global func6F70657265717528696E742C696E7429 ; operequ(int,int)
global func6F70657265717528766F69642A2C766F69642A29 ; operequ(void*,void*)
global func6F7065726E657128636861722C6368617229 ; operneq(char,char)
global func6F7065726E657128696E742C696E7429 ; operneq(int,int)
global func6F7065726E657128766F69642A2C766F69642A29 ; operneq(void*,void*)
global func6F70657267726528696E742C696E7429 ; opergre(int,int)
global func6F70657267726528766F69642A2C766F69642A29 ; opergre(void*,void*)
global func6F70657265677228696E742C696E7429 ; operegr(int,int)
global func6F70657265677228766F69642A2C766F69642A29 ; operegr(void*,void*)
global func6F7065726C657328696E742C696E7429 ; operles(int,int)
global func6F7065726C657328766F69642A2C766F69642A29 ; operles(void*,void*)
global func6F706572656C7328696E742C696E7429 ; operels(int,int)
global func6F706572656C7328766F69642A2C766F69642A29 ; operels(void*,void*)
global func6F7065726173732873616D65262C73616D6529 ; operass(same&,same)
global func6F7065727572652873616D652A29 ; operure(same*)
global func6F70657275706F28696E7429 ; operupo(int)
global func6F706572756E6528696E7429 ; operune(int)
global func6F706572756C6E28696E7429 ; operuln(int)
global func6F70657275626E28696E7429 ; operubn(int)

global func676574696E742829 ; getint()
global func7072696E7428696E7429 ; print(int)
global func676574636861722829 ; getchar()
global func7072696E74286368617229 ; print(char)

section .text
func6F70657273646528696E742629: ; opersde(int&)
mov rbx,[rsp-8]
mov ax,[rbx]
mov [rsp+8],ax
dec ax
mov [rbx],ax
ret
func6F70657275646528696E742629: ; operude(int&)
mov rbx,[rsp-8]
mov ax,[rbx]
dec ax
mov [rsp+8],ax
mov [rbx],ax
ret
func6F70657273696E28696E742629: ; opersin(int&)
mov rbx,[rsp-8]
mov ax,[rbx]
mov [rsp+8],ax
inc ax
mov [rbx],ax
ret
func6F70657275696E28696E742629: ; operuin(int&)
mov rbx,[rsp-8]
mov ax,[rbx]
inc ax
mov [rsp+8],ax
mov [rbx],ax
ret
func6F70657261616428696E74262C696E7429: ; operaad(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
add ax,[rbx]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F70657261737528696E74262C696E7429: ; operasu(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
sub [rbx],ax
mov ax,[rbx]
mov [rsp+8],ax
ret
func6F706572616D7528696E74262C696E7429: ; operamu(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
mul word[rbx]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F70657261646928696E74262C696E7429: ; operadi(int&,int)
mov rbx,[rsp-8]
mov ax,[rbx]
xor dx,dx
div word[rsp-10]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F706572616D6F28696E74262C696E7429: ; operamo(int&,int)
mov rbx,[rsp-8]
mov ax,[rbx]
xor dx,dx
div word[rsp-10]
mov [rbx],dx
mov [rsp+8],dx
ret
func6F70657261737228696E74262C696E7429: ; operasr(int&,int)
mov rbx,[rsp-8]
mov cx,[rsp-10]
shr word[rbx],cl
mov ax,[rbx]
mov [rsp+8],ax
ret
func6F70657261736C28696E74262C696E7429: ; operasl(int&,int)
mov rbx,[rsp-8]
mov cx,[rsp-10]
shl word[rbx],cl
mov ax,[rbx]
mov [rsp+8],ax
ret
func6F70657261646428696E742C696E7429: ; operadd(int,int)
mov ax,[rsp-2]
add ax,[rsp-4]
mov [rsp+8],ax
ret
func6F70657273756228696E742C696E7429: ; opersub(int,int)
mov ax,[rsp-2]
sub ax,[rsp-4]
mov [rsp+8],ax
ret
func6F7065726D756C28696E742C696E7429: ; opermul(int,int)
mov ax,[rsp-2]
mul word[rsp-4]
mov [rsp+8],ax
ret
func6F70657264697628696E742C696E7429: ; operdiv(int,int)
mov ax,[rsp-2]
xor dx,dx
div word[rsp-4]
mov [rsp+8],ax
ret
func6F7065726D6F6428696E742C696E7429: ; opermod(int,int)
mov ax,[rsp-2]
xor dx,dx
div word[rsp-4]
mov [rsp+8],dx
ret
func6F70657273687228696E742C696E7429: ; opershr(int,int)
mov ax,[rsp-2]
mov cx,[rsp-4]
shr ax,cl
mov [rsp+8],ax
ret
func6F70657273686C28696E742C696E7429: ; opershl(int,int)
mov ax,[rsp-2]
mov cx,[rsp-4]
shl ax,cl
mov [rsp+8],ax
ret
func6F706572786F7228696E742C696E7429: ; operxor(int,int)
mov ax,[rsp-2]
xor ax,[rsp-4]
mov [rsp+8],ax
ret
func6F70657262616E28696E742C696E7429: ; operban(int,int)
mov ax,[rsp-2]
and ax,[rsp-4]
mov [rsp+8],ax
ret
func6F706572626F7228696E742C696E7429: ; operbor(int,int)
mov ax,[rsp-2]
and ax,[rsp-4]
or [rsp+8],ax
ret
func6F70657261786F28696E74262C696E7429: ; operaxo(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
xor ax,[rbx]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F70657261616E28696E74262C696E7429: ; operaan(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
and ax,[rbx]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F706572616F7228696E74262C696E7429: ; operaor(int&,int)
mov rbx,[rsp-8]
mov ax,[rsp-10]
or ax,[rbx]
mov [rbx],ax
mov [rsp+8],ax
ret
func6F7065726164642873616D652A2C696E7429: ; operadd(same*,int)
mov rbx,[rsp-8]
movzx rax,word[rsp-10]
mul rcx
add rax,rbx
mov [rsp+8],rax
ret
func6F7065727375622873616D652A2C696E7429: ; opersub(same*,int)
mov rbx,[rsp-8]
movzx rax,word[rsp-10]
mul rcx
sub rbx,rax
mov [rsp+8],rbx
ret
func6F7065726161642873616D652A2A2C696E7429: ; operaad(same*&,int)
mov rbx,[rsp-8]
movzx rax,word[rsp-10]
add [rbx],rax
mov rax,[rbx]
mov [rsp+8],rax
ret
func6F7065726173752873616D652A2A2C696E7429: ; operasu(same*&,int)
mov rbx,[rsp-8]
movzx rax,word[rsp-10]
sub [rbx],rax
mov rax,[rbx]
mov [rsp+8],rax
ret
func6F70657275696E2873616D652A2629: ; operuin(same*&)
mov rbx,[rsp-8]
add [rbx],rcx
mov rax,[rbx]
mov [rsp+8],rax
ret
func6F70657273696E2873616D652A2629: ; opersin(same*&)
mov rbx,[rsp-8]
mov rax,[rbx]
add [rbx],rcx
mov [rsp+8],rax
ret
func6F7065727564652873616D652A2629: ; operude(same*&)
mov rbx,[rsp-8]
sub [rbx],rcx
mov rax,[rbx]
mov [rsp+8],rax
ret
func6F7065727364652873616D652A2629: ; opersde(same*&)
mov rbx,[rsp-8]
mov rax,[rbx]
sub [rbx],rcx
mov [rsp+8],rax
ret
_retfalse:
mov word[rsp+8],0
ret
_rettrue:
mov word[rsp+8],1
ret
func6F70657265717528636861722C6368617229: ; operequ(char,char)
mov al,[rsp-1]
cmp al,[rsp-2]
je _rettrue
jmp _retfalse
func6F70657265717528696E742C696E7429: ; operequ(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
je _rettrue
jmp _retfalse
func6F70657265717528766F69642A2C766F69642A29: ; operequ(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
je _rettrue
jmp _retfalse
func6F7065726E657128636861722C6368617229: ; operequ(char,char)
mov al,[rsp-1]
cmp al,[rsp-2]
jne _rettrue
jmp _retfalse
func6F7065726E657128696E742C696E7429: ; operneq(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
jne _rettrue
jmp _retfalse
func6F7065726E657128766F69642A2C766F69642A29: ; operneq(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
jne _rettrue
jmp _retfalse
func6F70657267726528696E742C696E7429: ; opergre(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
jg _rettrue
jmp _retfalse
func6F70657267726528766F69642A2C766F69642A29: ; opergre(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
jg _rettrue
jmp _retfalse
func6F70657265677228696E742C696E7429: ; operegr(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
jge _rettrue
jmp _retfalse
func6F70657265677228766F69642A2C766F69642A29: ; operegr(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
jge _rettrue
jmp _retfalse
func6F7065726C657328696E742C696E7429: ; operles(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
jl _rettrue
jmp _retfalse
func6F7065726C657328766F69642A2C766F69642A29: ; operles(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
jl _rettrue
jmp _retfalse
func6F706572656C7328696E742C696E7429: ; operels(int,int)
mov ax,[rsp-2]
cmp ax,[rsp-4]
jle _rettrue
jmp _retfalse
func6F706572656C7328766F69642A2C766F69642A29: ; operels(void*,void*)
mov rax,[rsp-8]
cmp rax,[rsp-16]
jle _rettrue
jmp _retfalse
func6F7065726173732873616D65262C73616D6529: ; operass(same&,same)
mov rbx,rsp
add rbx,8
mov rax, qword[rsp-8]
mov rdi,rsp
sub rdi,8
sub rdi,rcx
_loperass:
mov dl,[rdi]
mov [rax],dl
mov [rbx],dl
inc rax
inc rbx
inc rdi
loop _loperass
ret
func6F7065727572652873616D652A29: ; operure(same*)
mov rbx,rsp
add rbx,8
mov rdi,[rsp-8]
_loperure:
mov dl,[rdi]
mov [rbx],dl
inc rbx
inc rdi
loop _loperure
ret
func6F70657275706F28696E7429: ; operupo(int)
mov ax,[rsp-2]
mov [rsp+8],ax
ret
func6F706572756E6528696E7429: ; operune(int)
mov ax,[rsp-2]
neg ax
mov [rsp+8],ax
ret
func6F706572756C6E28696E7429: ; operuln(int)
mov ax,[rsp-2]
cmp ax,0
jz _rettrue
jmp _retfalse
func6F70657275626E28696E7429: ; operubn(int)
mov ax,[rsp-2]
not ax
mov [rsp+8],ax
ret
func676574696E742829: ; getint()
		sub rsp,1
		mov RBX,4
sl:		shl word [RSP+9],4
sr:		mov RAX,0
		mov RDI,0
		mov RSI,RSP
		mov RDX,1
		syscall
		movzx AX,byte [RSP]
		sub AL,0x30
		cmp AL,9
		jna sn
		sub AL,7
		cmp AL,0x0F
		ja sr
sn:		add word[RSP+9],AX
		dec RBX
		jnz sl
		inc RSP
		ret
func7072696E7428696E7429: ; print(int)
		sub RSP,2
		mov RCX,2
pl:		shl EAX,16
		movzx BX,byte [RSP]
		shl BX,4
		shr BL,4
		cmp BH,9
		jna pn1
		add BH,7
pn1:		cmp BL,9
		jna pn2
		add BL,7
pn2:		xchg BH,BL
		mov AX,BX
		inc RSP
		loop pl
		add EAX,0x30303030
		push RAX
		mov RAX,1
		mov RDI,1
		mov RSI,RSP
		mov RDX,4
		syscall
		pop RAX
		ret
func676574636861722829: ; getchar()
		mov RAX,0
		mov RDI,0
		mov RSI,RSP
		add RSI,8
		mov RDX,1
		syscall
		ret
func7072696E74286368617229: ; print(char)
		mov RAX,1
		mov RDI,1
		mov RSI,RSP
		dec RSI
		mov RDX,1
		syscall
		ret

_start:
sub rsp,2
call func6D61696E2829
pop bx
movzx rdi,bx
mov rax,60
syscall
